package misc;

import enums.URLEnum;

import java.util.Locale;
import java.util.ResourceBundle;

/**
 * Define un conjunto de constantes, cada una de las cuales se halla asociada a un URLEnum,
 * matcheando los diferentes ResourceBundle usados en la aplicacion;
 *
 * @author Jose Martin Rozanec;
 */
public class BundlesProvider {
    private static final ResourceBundle jFilechooserBundle = ResourceBundle.getBundle(URLEnum.getReference(URLEnum.FILECHOOSER_BUNDLE), new Locale("es"));
    private static final ResourceBundle textBundle = ResourceBundle.getBundle(URLEnum.getReference(URLEnum.TEXT_BUNDLE), new Locale("es"));
    private static final ResourceBundle femeninosBundle = ResourceBundle.getBundle(URLEnum.getReference(URLEnum.FEMENINOS_BUNDLE), new Locale("es"));
    private static final ResourceBundle dictionaryAfirmativeBundle = ResourceBundle.getBundle(URLEnum.getReference(URLEnum.DICTIONARY_AFIRMATIVE_BUNDLE), new Locale("es"));
    private static final ResourceBundle dictionaryTermsBundle = ResourceBundle.getBundle(URLEnum.getReference(URLEnum.DICTIONARY_TERMS_BUNDLE), new Locale("es"));
    private static final ResourceBundle theoryBundle = ResourceBundle.getBundle(URLEnum.getReference(URLEnum.THEORY_BUNDLE), new Locale("es"));
    private static final ResourceBundle pluralExceptionsBundle = ResourceBundle.getBundle(URLEnum.getReference(URLEnum.PLURAL_EXCEPTIONS_BUNDLE), new Locale("es"));


    /**
     * Devuelve el bundle a partir del URLEnum especificado. Devuelve null por defecto;
     *
     * @param urlEnum;
     * @return ResourceBundle;
     */
    public static ResourceBundle getBundle(URLEnum urlEnum) {
        switch (urlEnum) {
            case FILECHOOSER_BUNDLE:
                return jFilechooserBundle;
            case TEXT_BUNDLE:
                return textBundle;
            case FEMENINOS_BUNDLE:
                return femeninosBundle;
            case DICTIONARY_AFIRMATIVE_BUNDLE:
                return dictionaryAfirmativeBundle;
            case DICTIONARY_TERMS_BUNDLE:
                return dictionaryTermsBundle;
            case THEORY_BUNDLE:
                return theoryBundle;
            case PLURAL_EXCEPTIONS_BUNDLE:
                return pluralExceptionsBundle;
            default:
                return null;
        }
    }
}
